package hihocode;

import java.util.HashMap;
import java.util.Scanner;

public class UnionFind2 {

	private static final int MAX = 5000;
	
	private static class UF{
		int[] id;
		int[] sz;
		public UF(int n){
			id = new int[MAX];
			sz = new int[MAX];
			for(int i = 0; i < MAX; i++){
				id[i] = i;
				sz[i] = 1;
			}
		}

		private int find(int p){
	        if (p == id[p]) return p;
	        return id[p] = find(id[p]);
	    }
		
		public void union(int i, int j) {
			//找到i，j所在集合的代表元素
			int rp = find(i);
	        int rq = find(j);
	        if (rp == rq) return;
	        
	        //sz[rp]表示该元素代表集合的大小
	        if (sz[rp] < sz[rq]){
	            id[rp] = rq;
	            sz[rq] += sz[rp];
	        }else {
	            id[rq] = rp;
	            sz[rp] += sz[rq];
	        }
		}
		public boolean isUnion(int i, int j){
			return find(i) == find(j);
		}
	}

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		HashMap<String, Integer> map = new HashMap<>();
		int n = scanner.nextInt();
		int operate;
		String name1, name2;
		//维护着名字到下标的映射
		int index = 0;
		UF uf = new UF(2 * n);
		for(int i = 0; i < n; i++){
			operate = scanner.nextInt();
			name1 = scanner.next();
			name2 = scanner.next();
			scanner.nextLine();
			int nameIndex1, nameIndex2;
			if(map.containsKey(name1)){
				nameIndex1 = map.get(name1);
			}else{
				map.put(name1, index);
				nameIndex1 = index++;
			}
			if(map.containsKey(name2)){
				nameIndex2 = map.get(name2);
			}else{
				map.put(name2, index);
				nameIndex2 = index++;
			}
			if(operate == 0){
				uf.union(nameIndex1, nameIndex2);
			}else{
				if(uf.isUnion(nameIndex1, nameIndex2)){
					System.out.println("yes");
				}else{
					System.out.println("no");
				}
			}
		}
		scanner.close();
	}
}
